#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/3/9 11:34
# @Author : 闫峰
# @File    : sku_map.py
from utils.mysqlUtils.db_utils import DB
from utils.readFileUtils.read_sql import read_sql


def func1():
    sku_list = set()

    db = DB(database="test_jdw_database")
    sql1 = read_sql()
    res = db.execute_sql_many1(sql1, ())

    for i in res:

        if i['spu'] == '':
            sku_list.add(i['sku'])
        if i['spu'] != '':
            sql2 = """SELECT sku FROM `test_zhcxkj_center_product`.rb_product WHERE product_group_sku = %s;"""
            res1 = db.execute_sql_many1(sql2, (i["spu"],))
            for j in res1:
                sku_list.add(j['sku'])

    return sku_list,len(sku_list)


if __name__ == '__main__':
    print(func1())
